<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Agile Modbus: /home/runner/work/agile_modbus/agile_modbus/src/agile_modbus_rtu.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Agile Modbus
   &#160;<span id="projectnumber">1.1.4</span>
   </div>
   <div id="projectbrief">Lightweight modbus protocol stack.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('agile__modbus__rtu_8c_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">agile_modbus_rtu.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="agile__modbus__rtu_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="agile__modbus_8h.html">agile_modbus.h</a>&quot;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160; </div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#if AGILE_MODBUS_USING_RTU</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160; </div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="agile__modbus__rtu_8h.html">agile_modbus_rtu.h</a>&quot;</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno"><a class="line" href="group___r_t_u___private___constants.html#ga04218c2c5446512594e32a18242ef1e9">   28</a></span>&#160;<span class="keyword">static</span> <span class="keyword">const</span> uint8_t <a class="code" href="group___r_t_u___private___constants.html#ga04218c2c5446512594e32a18242ef1e9">_table_crc_hi</a>[] =</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;    {</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;        0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;        0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;        0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;        0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;        0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;        0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;        0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;        0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;        0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;        0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;        0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;        0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;        0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;        0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;        0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;        0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;        0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        0x80, 0x41, 0x00, 0xC1, 0x81, 0x40};</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160; </div>
<div class="line"><a name="l00058"></a><span class="lineno"><a class="line" href="group___r_t_u___private___constants.html#gae2ed306ffd807efd1a62f33caf690135">   58</a></span>&#160;<span class="keyword">static</span> <span class="keyword">const</span> uint8_t <a class="code" href="group___r_t_u___private___constants.html#gae2ed306ffd807efd1a62f33caf690135">_table_crc_lo</a>[] =</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    {</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;        0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06,</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;        0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD,</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;        0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;        0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A,</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;        0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4,</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;        0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;        0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3,</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;        0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4,</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A,</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29,</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;        0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED,</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;        0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60,</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;        0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67,</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;        0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F,</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;        0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68,</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;        0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E,</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;        0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;        0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71,</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;        0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92,</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;        0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;        0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B,</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;        0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B,</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;        0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;        0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42,</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;        0x43, 0x83, 0x41, 0x81, 0x80, 0x40};</div>
<div class="line"><a name="l00100"></a><span class="lineno"><a class="line" href="group___r_t_u___private___functions.html#ga917aedd343bdcfd4d4a7b9fc80db2a17">  100</a></span>&#160;<span class="keyword">static</span> uint16_t <a class="code" href="group___r_t_u___private___functions.html#ga917aedd343bdcfd4d4a7b9fc80db2a17">agile_modbus_rtu_crc16</a>(uint8_t *buffer, uint16_t buffer_length)</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;{</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    uint8_t crc_hi = 0xFF; <span class="comment">/* high CRC byte initialized */</span></div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;    uint8_t crc_lo = 0xFF; <span class="comment">/* low CRC byte initialized */</span></div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;        <span class="comment">/* will index into CRC lookup */</span></div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160; </div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <span class="comment">/* pass through message buffer */</span></div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    <span class="keywordflow">while</span> (buffer_length--) {</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;        i = crc_hi ^ *buffer++; <span class="comment">/* calculate the CRC  */</span></div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;        crc_hi = crc_lo ^ <a class="code" href="group___r_t_u___private___constants.html#ga04218c2c5446512594e32a18242ef1e9">_table_crc_hi</a>[i];</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;        crc_lo = <a class="code" href="group___r_t_u___private___constants.html#gae2ed306ffd807efd1a62f33caf690135">_table_crc_lo</a>[i];</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;    }</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160; </div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    <span class="keywordflow">return</span> (crc_hi &lt;&lt; 8 | crc_lo);</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;}</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160; </div>
<div class="line"><a name="l00122"></a><span class="lineno"><a class="line" href="group___r_t_u___private___functions.html#ga904257d5d6c88f9f81447bc0accf9b62">  122</a></span>&#160;<span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="group___r_t_u___private___functions.html#ga904257d5d6c88f9f81447bc0accf9b62">agile_modbus_rtu_set_slave</a>(<a class="code" href="structagile__modbus.html">agile_modbus_t</a> *ctx, <span class="keywordtype">int</span> slave)</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;{</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    ctx-&gt;<a class="code" href="structagile__modbus.html#acd02aacf2081b397ee378e21858b2dd7">slave</a> = slave;</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;}</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160; </div>
<div class="line"><a name="l00137"></a><span class="lineno"><a class="line" href="group___r_t_u___private___functions.html#ga604461d9c9522b5352ceda519eeae006">  137</a></span>&#160;<span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="group___r_t_u___private___functions.html#ga604461d9c9522b5352ceda519eeae006">agile_modbus_rtu_build_request_basis</a>(<a class="code" href="structagile__modbus.html">agile_modbus_t</a> *ctx, <span class="keywordtype">int</span> <span class="keyword">function</span>,</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;                                                <span class="keywordtype">int</span> addr, <span class="keywordtype">int</span> nb,</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;                                                uint8_t *req)</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;{</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    req[0] = ctx-&gt;<a class="code" href="structagile__modbus.html#acd02aacf2081b397ee378e21858b2dd7">slave</a>;</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    req[1] = <span class="keyword">function</span>;</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    req[2] = addr &gt;&gt; 8;</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    req[3] = addr &amp; 0x00ff;</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    req[4] = nb &gt;&gt; 8;</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    req[5] = nb &amp; 0x00ff;</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160; </div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group___r_t_u___exported___constants.html#gace39790c52a0a34e637c9ecf35b2ddc1">AGILE_MODBUS_RTU_PRESET_REQ_LENGTH</a>;</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;}</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160; </div>
<div class="line"><a name="l00157"></a><span class="lineno"><a class="line" href="group___r_t_u___private___functions.html#ga0bbede450717d31223094f8e795e0e89">  157</a></span>&#160;<span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="group___r_t_u___private___functions.html#ga0bbede450717d31223094f8e795e0e89">agile_modbus_rtu_build_response_basis</a>(<a class="code" href="structagile__modbus__sft.html">agile_modbus_sft_t</a> *sft, uint8_t *rsp)</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;{</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;    rsp[0] = sft-&gt;<a class="code" href="structagile__modbus__sft.html#ab9ada92752df1ac2d7597a43eb1cd374">slave</a>;</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;    rsp[1] = sft-&gt;<a class="code" href="structagile__modbus__sft.html#afe1918bcff8e86066656a68de876b873">function</a>;</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160; </div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group___r_t_u___exported___constants.html#gac42d8c18189788ecbac043e2235944db">AGILE_MODBUS_RTU_PRESET_RSP_LENGTH</a>;</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;}</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160; </div>
<div class="line"><a name="l00172"></a><span class="lineno"><a class="line" href="group___r_t_u___private___functions.html#gacd396678c9cc5a5c77cba6615eb212bd">  172</a></span>&#160;<span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="group___r_t_u___private___functions.html#gacd396678c9cc5a5c77cba6615eb212bd">agile_modbus_rtu_prepare_response_tid</a>(<span class="keyword">const</span> uint8_t *req, <span class="keywordtype">int</span> *req_length)</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;{</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;    (void)req;</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;    (*req_length) -= <a class="code" href="group___r_t_u___exported___constants.html#gaf5e4f433bd581c089fa6d00c1f8b4e50">AGILE_MODBUS_RTU_CHECKSUM_LENGTH</a>;</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;    <span class="comment">/* No TID */</span></div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;    <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;}</div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160; </div>
<div class="line"><a name="l00187"></a><span class="lineno"><a class="line" href="group___r_t_u___private___functions.html#ga1cb91eb00f06868c4c5b85e67f7ef126">  187</a></span>&#160;<span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="group___r_t_u___private___functions.html#ga1cb91eb00f06868c4c5b85e67f7ef126">agile_modbus_rtu_send_msg_pre</a>(uint8_t *req, <span class="keywordtype">int</span> req_length)</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;{</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;    uint16_t crc = <a class="code" href="group___r_t_u___private___functions.html#ga917aedd343bdcfd4d4a7b9fc80db2a17">agile_modbus_rtu_crc16</a>(req, req_length);</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;    req[req_length++] = crc &gt;&gt; 8;</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;    req[req_length++] = crc &amp; 0x00FF;</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160; </div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;    <span class="keywordflow">return</span> req_length;</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;}</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160; </div>
<div class="line"><a name="l00203"></a><span class="lineno"><a class="line" href="group___r_t_u___private___functions.html#gaa7ff9945c4910eafae9b737957ae6cad">  203</a></span>&#160;<span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="group___r_t_u___private___functions.html#gaa7ff9945c4910eafae9b737957ae6cad">agile_modbus_rtu_check_integrity</a>(<a class="code" href="structagile__modbus.html">agile_modbus_t</a> *ctx, uint8_t *msg, <span class="keyword">const</span> <span class="keywordtype">int</span> msg_length)</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;{</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;    uint16_t crc_calculated;</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;    uint16_t crc_received;</div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;    (void)ctx;</div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;    crc_calculated = <a class="code" href="group___r_t_u___private___functions.html#ga917aedd343bdcfd4d4a7b9fc80db2a17">agile_modbus_rtu_crc16</a>(msg, msg_length - 2);</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;    crc_received = (msg[msg_length - 2] &lt;&lt; 8) | msg[msg_length - 1];</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160; </div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;    <span class="comment">/* Check CRC of msg */</span></div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;    <span class="keywordflow">if</span> (crc_calculated == crc_received)</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;        <span class="keywordflow">return</span> msg_length;</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160; </div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;    <span class="keywordflow">return</span> -1;</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;}</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160; </div>
<div class="line"><a name="l00227"></a><span class="lineno"><a class="line" href="group___r_t_u___private___functions.html#gabc4beee96e865a624d3d8129633c8765">  227</a></span>&#160;<span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="group___r_t_u___private___functions.html#gabc4beee96e865a624d3d8129633c8765">agile_modbus_rtu_pre_check_confirmation</a>(<a class="code" href="structagile__modbus.html">agile_modbus_t</a> *ctx, <span class="keyword">const</span> uint8_t *req,</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;                                                   <span class="keyword">const</span> uint8_t *rsp, <span class="keywordtype">int</span> rsp_length)</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;{</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;    <span class="comment">/* Check responding slave is the slave we requested (except for broacast</span></div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;<span class="comment">     * request) */</span></div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;    (void)ctx;</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;    (void)rsp_length;</div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;    <span class="keywordflow">if</span> (req[0] != rsp[0] &amp;&amp; req[0] != <a class="code" href="group___modbus___constants.html#ga224b2d0e89248e2928b13486362e1dc2">AGILE_MODBUS_BROADCAST_ADDRESS</a>)</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;        <span class="keywordflow">return</span> -1;</div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160; </div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;    <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;}</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160; </div>
<div class="line"><a name="l00251"></a><span class="lineno"><a class="line" href="group___r_t_u___private___constants.html#ga380ad4931059280836d853cde7bcee43">  251</a></span>&#160;<span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structagile__modbus__backend.html">agile_modbus_backend_t</a> <a class="code" href="group___r_t_u___private___constants.html#ga380ad4931059280836d853cde7bcee43">agile_modbus_rtu_backend</a> =</div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;    {</div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;        <a class="code" href="group___c_o_m_m_o_n___exported___types.html#gga88d4f826eda73ae5fc071856f70683fdab0a15fe132d3f733ee4052ea2f0bd391">AGILE_MODBUS_BACKEND_TYPE_RTU</a>,</div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;        <a class="code" href="group___r_t_u___exported___constants.html#ga0acfe5200e87289af0e996e28a5014ef">AGILE_MODBUS_RTU_HEADER_LENGTH</a>,</div>
<div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;        <a class="code" href="group___r_t_u___exported___constants.html#gaf5e4f433bd581c089fa6d00c1f8b4e50">AGILE_MODBUS_RTU_CHECKSUM_LENGTH</a>,</div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;        <a class="code" href="group___r_t_u___exported___constants.html#ga78548481d5cdf9c62b7b7a619be62507">AGILE_MODBUS_RTU_MAX_ADU_LENGTH</a>,</div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;        <a class="code" href="group___r_t_u___private___functions.html#ga904257d5d6c88f9f81447bc0accf9b62">agile_modbus_rtu_set_slave</a>,</div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;        <a class="code" href="group___r_t_u___private___functions.html#ga604461d9c9522b5352ceda519eeae006">agile_modbus_rtu_build_request_basis</a>,</div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;        <a class="code" href="group___r_t_u___private___functions.html#ga0bbede450717d31223094f8e795e0e89">agile_modbus_rtu_build_response_basis</a>,</div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;        <a class="code" href="group___r_t_u___private___functions.html#gacd396678c9cc5a5c77cba6615eb212bd">agile_modbus_rtu_prepare_response_tid</a>,</div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;        <a class="code" href="group___r_t_u___private___functions.html#ga1cb91eb00f06868c4c5b85e67f7ef126">agile_modbus_rtu_send_msg_pre</a>,</div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;        <a class="code" href="group___r_t_u___private___functions.html#gaa7ff9945c4910eafae9b737957ae6cad">agile_modbus_rtu_check_integrity</a>,</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;        <a class="code" href="group___r_t_u___private___functions.html#gabc4beee96e865a624d3d8129633c8765">agile_modbus_rtu_pre_check_confirmation</a>};</div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160; </div>
<div class="line"><a name="l00282"></a><span class="lineno"><a class="line" href="group___r_t_u___exported___functions.html#ga96821440a21db41bb7b662ea8ff346ec">  282</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="group___r_t_u___exported___functions.html#ga96821440a21db41bb7b662ea8ff346ec">agile_modbus_rtu_init</a>(<a class="code" href="structagile__modbus__rtu.html">agile_modbus_rtu_t</a> *ctx, uint8_t *send_buf, <span class="keywordtype">int</span> send_bufsz, uint8_t *read_buf, <span class="keywordtype">int</span> read_bufsz)</div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;{</div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;    <a class="code" href="group___c_o_m_m_o_n___exported___functions.html#ga520bd6e5aa1521ebe24a058f8bc9e6f5">agile_modbus_common_init</a>(&amp;(ctx-&gt;<a class="code" href="structagile__modbus__rtu.html#a0cedf071c64b853a46524100bbf4229d">_ctx</a>), send_buf, send_bufsz, read_buf, read_bufsz);</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;    ctx-&gt;<a class="code" href="structagile__modbus__rtu.html#a0cedf071c64b853a46524100bbf4229d">_ctx</a>.<a class="code" href="structagile__modbus.html#aa9d48739d05877966b473beeb61176b7">backend</a> = &amp;<a class="code" href="group___r_t_u___private___constants.html#ga380ad4931059280836d853cde7bcee43">agile_modbus_rtu_backend</a>;</div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;    ctx-&gt;<a class="code" href="structagile__modbus__rtu.html#a0cedf071c64b853a46524100bbf4229d">_ctx</a>.<a class="code" href="structagile__modbus.html#ae1ab077d16f51a6dbaaa5e3136cf6053">backend_data</a> = ctx;</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160; </div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;    <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;}</div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160; </div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* AGILE_MODBUS_USING_RTU */</span><span class="preprocessor"></span></div>
<div class="ttc" id="aagile__modbus_8h_html"><div class="ttname"><a href="agile__modbus_8h.html">agile_modbus.h</a></div><div class="ttdoc">Agile Modbus software package common header file.</div></div>
<div class="ttc" id="aagile__modbus__rtu_8h_html"><div class="ttname"><a href="agile__modbus__rtu_8h.html">agile_modbus_rtu.h</a></div><div class="ttdoc">Agile Modbus package RTU header file.</div></div>
<div class="ttc" id="agroup___c_o_m_m_o_n___exported___functions_html_ga520bd6e5aa1521ebe24a058f8bc9e6f5"><div class="ttname"><a href="group___c_o_m_m_o_n___exported___functions.html#ga520bd6e5aa1521ebe24a058f8bc9e6f5">agile_modbus_common_init</a></div><div class="ttdeci">void agile_modbus_common_init(agile_modbus_t *ctx, uint8_t *send_buf, int send_bufsz, uint8_t *read_buf, int read_bufsz)</div><div class="ttdoc">initialize modbus handle</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8c_source.html#l00257">agile_modbus.c:257</a></div></div>
<div class="ttc" id="agroup___c_o_m_m_o_n___exported___types_html_gga88d4f826eda73ae5fc071856f70683fdab0a15fe132d3f733ee4052ea2f0bd391"><div class="ttname"><a href="group___c_o_m_m_o_n___exported___types.html#gga88d4f826eda73ae5fc071856f70683fdab0a15fe132d3f733ee4052ea2f0bd391">AGILE_MODBUS_BACKEND_TYPE_RTU</a></div><div class="ttdeci">@ AGILE_MODBUS_BACKEND_TYPE_RTU</div><div class="ttdoc">RTU.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00165">agile_modbus.h:165</a></div></div>
<div class="ttc" id="agroup___modbus___constants_html_ga224b2d0e89248e2928b13486362e1dc2"><div class="ttname"><a href="group___modbus___constants.html#ga224b2d0e89248e2928b13486362e1dc2">AGILE_MODBUS_BROADCAST_ADDRESS</a></div><div class="ttdeci">#define AGILE_MODBUS_BROADCAST_ADDRESS</div><div class="ttdoc">Modbus broadcast address.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00069">agile_modbus.h:69</a></div></div>
<div class="ttc" id="agroup___r_t_u___exported___constants_html_ga0acfe5200e87289af0e996e28a5014ef"><div class="ttname"><a href="group___r_t_u___exported___constants.html#ga0acfe5200e87289af0e996e28a5014ef">AGILE_MODBUS_RTU_HEADER_LENGTH</a></div><div class="ttdeci">#define AGILE_MODBUS_RTU_HEADER_LENGTH</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8h_source.html#l00032">agile_modbus_rtu.h:32</a></div></div>
<div class="ttc" id="agroup___r_t_u___exported___constants_html_ga78548481d5cdf9c62b7b7a619be62507"><div class="ttname"><a href="group___r_t_u___exported___constants.html#ga78548481d5cdf9c62b7b7a619be62507">AGILE_MODBUS_RTU_MAX_ADU_LENGTH</a></div><div class="ttdeci">#define AGILE_MODBUS_RTU_MAX_ADU_LENGTH</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8h_source.html#l00045">agile_modbus_rtu.h:45</a></div></div>
<div class="ttc" id="agroup___r_t_u___exported___constants_html_gac42d8c18189788ecbac043e2235944db"><div class="ttname"><a href="group___r_t_u___exported___constants.html#gac42d8c18189788ecbac043e2235944db">AGILE_MODBUS_RTU_PRESET_RSP_LENGTH</a></div><div class="ttdeci">#define AGILE_MODBUS_RTU_PRESET_RSP_LENGTH</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8h_source.html#l00034">agile_modbus_rtu.h:34</a></div></div>
<div class="ttc" id="agroup___r_t_u___exported___constants_html_gace39790c52a0a34e637c9ecf35b2ddc1"><div class="ttname"><a href="group___r_t_u___exported___constants.html#gace39790c52a0a34e637c9ecf35b2ddc1">AGILE_MODBUS_RTU_PRESET_REQ_LENGTH</a></div><div class="ttdeci">#define AGILE_MODBUS_RTU_PRESET_REQ_LENGTH</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8h_source.html#l00033">agile_modbus_rtu.h:33</a></div></div>
<div class="ttc" id="agroup___r_t_u___exported___constants_html_gaf5e4f433bd581c089fa6d00c1f8b4e50"><div class="ttname"><a href="group___r_t_u___exported___constants.html#gaf5e4f433bd581c089fa6d00c1f8b4e50">AGILE_MODBUS_RTU_CHECKSUM_LENGTH</a></div><div class="ttdeci">#define AGILE_MODBUS_RTU_CHECKSUM_LENGTH</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8h_source.html#l00036">agile_modbus_rtu.h:36</a></div></div>
<div class="ttc" id="agroup___r_t_u___exported___functions_html_ga96821440a21db41bb7b662ea8ff346ec"><div class="ttname"><a href="group___r_t_u___exported___functions.html#ga96821440a21db41bb7b662ea8ff346ec">agile_modbus_rtu_init</a></div><div class="ttdeci">int agile_modbus_rtu_init(agile_modbus_rtu_t *ctx, uint8_t *send_buf, int send_bufsz, uint8_t *read_buf, int read_bufsz)</div><div class="ttdoc">RTU initialization.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00282">agile_modbus_rtu.c:282</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___constants_html_ga04218c2c5446512594e32a18242ef1e9"><div class="ttname"><a href="group___r_t_u___private___constants.html#ga04218c2c5446512594e32a18242ef1e9">_table_crc_hi</a></div><div class="ttdeci">static const uint8_t _table_crc_hi[]</div><div class="ttdoc">Table of CRC values for high-order byte.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00028">agile_modbus_rtu.c:28</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___constants_html_ga380ad4931059280836d853cde7bcee43"><div class="ttname"><a href="group___r_t_u___private___constants.html#ga380ad4931059280836d853cde7bcee43">agile_modbus_rtu_backend</a></div><div class="ttdeci">static const agile_modbus_backend_t agile_modbus_rtu_backend</div><div class="ttdoc">RTU backend interface.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00251">agile_modbus_rtu.c:251</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___constants_html_gae2ed306ffd807efd1a62f33caf690135"><div class="ttname"><a href="group___r_t_u___private___constants.html#gae2ed306ffd807efd1a62f33caf690135">_table_crc_lo</a></div><div class="ttdeci">static const uint8_t _table_crc_lo[]</div><div class="ttdoc">Table of CRC values for low-order byte.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00058">agile_modbus_rtu.c:58</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___functions_html_ga0bbede450717d31223094f8e795e0e89"><div class="ttname"><a href="group___r_t_u___private___functions.html#ga0bbede450717d31223094f8e795e0e89">agile_modbus_rtu_build_response_basis</a></div><div class="ttdeci">static int agile_modbus_rtu_build_response_basis(agile_modbus_sft_t *sft, uint8_t *rsp)</div><div class="ttdoc">RTU builds the basic response message interface (header message)</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00157">agile_modbus_rtu.c:157</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___functions_html_ga1cb91eb00f06868c4c5b85e67f7ef126"><div class="ttname"><a href="group___r_t_u___private___functions.html#ga1cb91eb00f06868c4c5b85e67f7ef126">agile_modbus_rtu_send_msg_pre</a></div><div class="ttdeci">static int agile_modbus_rtu_send_msg_pre(uint8_t *req, int req_length)</div><div class="ttdoc">RTU pre-send data interface.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00187">agile_modbus_rtu.c:187</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___functions_html_ga604461d9c9522b5352ceda519eeae006"><div class="ttname"><a href="group___r_t_u___private___functions.html#ga604461d9c9522b5352ceda519eeae006">agile_modbus_rtu_build_request_basis</a></div><div class="ttdeci">static int agile_modbus_rtu_build_request_basis(agile_modbus_t *ctx, int function, int addr, int nb, uint8_t *req)</div><div class="ttdoc">RTU builds the basic request message interface (header message)</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00137">agile_modbus_rtu.c:137</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___functions_html_ga904257d5d6c88f9f81447bc0accf9b62"><div class="ttname"><a href="group___r_t_u___private___functions.html#ga904257d5d6c88f9f81447bc0accf9b62">agile_modbus_rtu_set_slave</a></div><div class="ttdeci">static int agile_modbus_rtu_set_slave(agile_modbus_t *ctx, int slave)</div><div class="ttdoc">RTU sets the address interface.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00122">agile_modbus_rtu.c:122</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___functions_html_ga917aedd343bdcfd4d4a7b9fc80db2a17"><div class="ttname"><a href="group___r_t_u___private___functions.html#ga917aedd343bdcfd4d4a7b9fc80db2a17">agile_modbus_rtu_crc16</a></div><div class="ttdeci">static uint16_t agile_modbus_rtu_crc16(uint8_t *buffer, uint16_t buffer_length)</div><div class="ttdoc">RTU CRC16 calculation.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00100">agile_modbus_rtu.c:100</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___functions_html_gaa7ff9945c4910eafae9b737957ae6cad"><div class="ttname"><a href="group___r_t_u___private___functions.html#gaa7ff9945c4910eafae9b737957ae6cad">agile_modbus_rtu_check_integrity</a></div><div class="ttdeci">static int agile_modbus_rtu_check_integrity(agile_modbus_t *ctx, uint8_t *msg, const int msg_length)</div><div class="ttdoc">RTU check received data integrity interface (CRC16 comparison)</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00203">agile_modbus_rtu.c:203</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___functions_html_gabc4beee96e865a624d3d8129633c8765"><div class="ttname"><a href="group___r_t_u___private___functions.html#gabc4beee96e865a624d3d8129633c8765">agile_modbus_rtu_pre_check_confirmation</a></div><div class="ttdeci">static int agile_modbus_rtu_pre_check_confirmation(agile_modbus_t *ctx, const uint8_t *req, const uint8_t *rsp, int rsp_length)</div><div class="ttdoc">RTU pre-check confirmation interface (request response address comparison)</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00227">agile_modbus_rtu.c:227</a></div></div>
<div class="ttc" id="agroup___r_t_u___private___functions_html_gacd396678c9cc5a5c77cba6615eb212bd"><div class="ttname"><a href="group___r_t_u___private___functions.html#gacd396678c9cc5a5c77cba6615eb212bd">agile_modbus_rtu_prepare_response_tid</a></div><div class="ttdeci">static int agile_modbus_rtu_prepare_response_tid(const uint8_t *req, int *req_length)</div><div class="ttdoc">RTU ready response interface.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8c_source.html#l00172">agile_modbus_rtu.c:172</a></div></div>
<div class="ttc" id="astructagile__modbus__backend_html"><div class="ttname"><a href="structagile__modbus__backend.html">agile_modbus_backend</a></div><div class="ttdoc">Agile Modbus backend interface structure.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00198">agile_modbus.h:198</a></div></div>
<div class="ttc" id="astructagile__modbus__rtu_html"><div class="ttname"><a href="structagile__modbus__rtu.html">agile_modbus_rtu</a></div><div class="ttdoc">RTU structure.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8h_source.html#l00057">agile_modbus_rtu.h:57</a></div></div>
<div class="ttc" id="astructagile__modbus__rtu_html_a0cedf071c64b853a46524100bbf4229d"><div class="ttname"><a href="structagile__modbus__rtu.html#a0cedf071c64b853a46524100bbf4229d">agile_modbus_rtu::_ctx</a></div><div class="ttdeci">agile_modbus_t _ctx</div><div class="ttdoc">modbus handle</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus__rtu_8h_source.html#l00058">agile_modbus_rtu.h:58</a></div></div>
<div class="ttc" id="astructagile__modbus__sft_html"><div class="ttname"><a href="structagile__modbus__sft.html">agile_modbus_sft</a></div><div class="ttdoc">contains the modbus header parameter structure</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00187">agile_modbus.h:187</a></div></div>
<div class="ttc" id="astructagile__modbus__sft_html_ab9ada92752df1ac2d7597a43eb1cd374"><div class="ttname"><a href="structagile__modbus__sft.html#ab9ada92752df1ac2d7597a43eb1cd374">agile_modbus_sft::slave</a></div><div class="ttdeci">int slave</div><div class="ttdoc">slave address</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00188">agile_modbus.h:188</a></div></div>
<div class="ttc" id="astructagile__modbus__sft_html_afe1918bcff8e86066656a68de876b873"><div class="ttname"><a href="structagile__modbus__sft.html#afe1918bcff8e86066656a68de876b873">agile_modbus_sft::function</a></div><div class="ttdeci">int function</div><div class="ttdoc">function code</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00189">agile_modbus.h:189</a></div></div>
<div class="ttc" id="astructagile__modbus_html"><div class="ttname"><a href="structagile__modbus.html">agile_modbus</a></div><div class="ttdoc">Agile Modbus structure.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00217">agile_modbus.h:217</a></div></div>
<div class="ttc" id="astructagile__modbus_html_aa9d48739d05877966b473beeb61176b7"><div class="ttname"><a href="structagile__modbus.html#aa9d48739d05877966b473beeb61176b7">agile_modbus::backend</a></div><div class="ttdeci">const agile_modbus_backend_t * backend</div><div class="ttdoc">Backend interface.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00227">agile_modbus.h:227</a></div></div>
<div class="ttc" id="astructagile__modbus_html_acd02aacf2081b397ee378e21858b2dd7"><div class="ttname"><a href="structagile__modbus.html#acd02aacf2081b397ee378e21858b2dd7">agile_modbus::slave</a></div><div class="ttdeci">int slave</div><div class="ttdoc">slave address</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00218">agile_modbus.h:218</a></div></div>
<div class="ttc" id="astructagile__modbus_html_ae1ab077d16f51a6dbaaa5e3136cf6053"><div class="ttname"><a href="structagile__modbus.html#ae1ab077d16f51a6dbaaa5e3136cf6053">agile_modbus::backend_data</a></div><div class="ttdeci">void * backend_data</div><div class="ttdoc">Backend data, pointing to RTU or TCP structure.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00228">agile_modbus.h:228</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="agile__modbus__rtu_8c.html">agile_modbus_rtu.c</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
